# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=py3-jsonschema
pkgver=4.6.2
pkgrel=0
pkgdesc="An implementation of JSON Schema validation for Python"
url="https://github.com/Julian/jsonschema"
arch="noarch"
license="MIT"
depends="python3 py3-pyrsistent py3-attrs py3-six"
makedepends="py3-build py3-installer py3-hatchling py3-hatch-vcs py3-setuptools_scm py3-wheel"
checkdepends="py3-twisted py3-pytest py3-tox"
source="https://files.pythonhosted.org/packages/source/j/jsonschema/jsonschema-$pkgver.tar.gz"
builddir="$srcdir/jsonschema-$pkgver"

replaces="py-jsonschema" # Backwards compatibility
provides="py-jsonschema=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	python3 -m build --no-isolation --wheel
}

check() {
	tox -e py310-noextra-tests --sitepackages
}

package() {
	python3 -m installer -d "$pkgdir" \
		dist/jsonschema-$pkgver-py3-none-any.whl

	# Add version suffix to executable files.
	local path; for path in "$pkgdir"/usr/bin/*; do
		mv "$path" "$path"-3
	done

	ln -s jsonschema-3 "$pkgdir"/usr/bin/jsonschema
}

sha512sums="
e41d6bda1bd6b12174201a70b5ad5209ab7c445faa6c947408f0fbc255839f3379ffe8b539760d993b435972936e4052300dbc420d4b87051f33180bced7efb2  jsonschema-4.6.2.tar.gz
"
